package org.domain.sigepac.session;

import java.util.List;

import org.domain.sigepac.Entity.Professor;
import org.domain.sigepac.repository.RepositorioProfessor;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Factory;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.datamodel.DataModel;
import org.jboss.seam.annotations.datamodel.DataModelSelection;

@Name("professorList")
@Scope(ScopeType.CONVERSATION)
public class ProfessorList {



	@In
	private RepositorioProfessor repositorioProfessor;

	@DataModel
	private List<Professor> listaProfessores;


	@DataModelSelection
	private Professor professor;

	@Out(required=false)
	private Professor professorPesquisa;


	private Integer paginacao=20;

	@Factory("listaProfessores")
	public void listar(){
		listaProfessores=repositorioProfessor.listar();
	}

	public void pesquisar(){
		listaProfessores=repositorioProfessor.pesquisarPorNome(professorPesquisa.getNome());
	}

	public Integer getPaginacao() {
		return paginacao;
	}

	public void setProfessorPesquisa(Professor professorPesquisa) {
		this.professorPesquisa = professorPesquisa;
	}
	public Professor getProfessorPesquisa() {
		if(professorPesquisa==null)
			professorPesquisa=new Professor();
		return professorPesquisa;
	}

}
